package com.project.bean;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.time.LocalDate;
import java.util.List;

/**
 * 订单实体类
 */
public class OrderBean {
    /**订单编号*/
    private int id;
    /**收货人*/
    @NotBlank(message = "收货人必须填写")
    private String accept;
    /**收货人电话*/
    @NotBlank(message = "收货人电话必须填写")
    @Pattern(regexp = "1[3578]\\d{9}",message = "电话必须是13、15、17、18开始的11位数")
    private String tel;
    /**送货地址*/
    @NotBlank(message = "送货地址必须填写")
    @Pattern(regexp = "[0-9\\u4e00-\\u9fa5]{3,}",message = "送货地址只能包含3位以上的数字和中文")
    private String address;
    /**下单时间*/
    private LocalDate orderDate = LocalDate.now() ;
    /**订单总价*/
    private int totalPrice;
    /**状态*/
    private String status = "未发货";
    /**下单用户*/
    private UserBean user;
    /**订单明细集合*/
    private List<OrderInfoBean> infoList;

    public OrderBean(String accept, String tel, String address, int totalPrice, int userId) {
        this.accept = accept;
        this.tel = tel;
        this.address = address;
        this.totalPrice = totalPrice;
        this.user = new UserBean();
        this.user.setId(userId);
    }

    public OrderBean() {
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getAccept() {
        return accept;
    }

    public void setAccept(String accept) {
        this.accept = accept;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public LocalDate getOrderDate() {
        return orderDate;
    }

    public void setOrderDate(LocalDate orderDate) {
        this.orderDate = orderDate;
    }

    public int getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(int totalPrice) {
        this.totalPrice = totalPrice;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public UserBean getUser() {
        return user;
    }

    public void setUser(UserBean user) {
        this.user = user;
    }

    public List<OrderInfoBean> getInfoList() {
        return infoList;
    }

    @Override
    public String toString() {
        return "OrderBean{" +
                "id=" + id +
                ", accept='" + accept + '\'' +
                ", tel='" + tel + '\'' +
                ", address='" + address + '\'' +
                ", orderDate=" + orderDate +
                ", totalPrice=" + totalPrice +
                ", status='" + status + '\'' +
                ", user=" + user +
                ", infoList=" + infoList +
                '}';
    }

    public void setInfoList(List<OrderInfoBean> infoList) {
        this.infoList = infoList;
    }
}
